//
//  LoginViewController.m
//  intelligent
//
//  Created by 甘世清 on 2024/2/5.
//

#import "LoginViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColor.whiteColor;
    
}
- (void)SQ_UIViewForSelfView{
    UIImageView * bgImage = [[UIImageView alloc]init];
    bgImage.image = SQGetImage(@"logo");
    bgImage.clipsToBounds = YES;
    bgImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:bgImage];
    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(88);
        make.top.equalTo(self.view).offset(TopHeight+30);
    }];
    
    HeaderView * btn = [[HeaderView alloc]init];
    btn.font = FONT_SEMIBOLD(19);
    btn.text = SQNSLocalString(@"一键快捷登录");
    btn.colorString = @"#333333";
    btn.layer.cornerRadius = 6;
    btn.backgroundColor = [UIColor colorWithHexString:@"#4AF8CE"];
    [btn.btn addTarget:self action:@selector(SQ_buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom).offset(-210-FootHeight);
        make.height.mas_equalTo(54);
        make.width.mas_equalTo(SCREEN_WIDETH-32);
        make.centerX.equalTo(self.view);
    }];
}
-(void)SQ_buttonClick{
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    NSString * account = [Manager SQ_stringForKey:@"account"];
    if (![account isNotEmpty]) {
        account = [Manager SQ_getStringID];
        [Manager SQ_SetObject:account FormKey:@"account"];
    }
    [dic setObject:account forKey:@"account"];
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    [HttpTool post:@"user/touristLogin" paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        NSDictionary * data = [[NSDictionary alloc]initWithDictionary:httpModel.data];
        UserModel * model = [UserModel mj_objectWithKeyValues:data];
        [UserModel updateLocalUserModel:model];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[Manager SQ_getViewController]];
         self.view.window.rootViewController = nav;
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
}
 
 
@end
